"""
@author: chenl
@file: 5-31-下载图片.py
@time: 2023/5/31 9:49
"""

# 2.从三创官网上下载所有图片
import re
import requests


def scrape_website(url):
    response = requests.get(url)
    if response.status_code == 200:
        patten = r'<img.*?src\s*=\s*["\'](.*?)["\'].*?>'
        content = response.text
        matched_content = re.findall(patten, content)
        for image_url in matched_content:
            image_response = requests.get(image_url)
            if image_response.status_code == 200:
                print("爬取到的图片:", image_url)
            else:
                print("获取图片失败:", image_url)
    else:
        print("请求失败")


url = "https://www.sanchuangedu.cn/"

scrape_website(url)
